... from GtkStyleProperty to GtkCssStyleProperty.
#include "gtkcsstypesprivate.h"
#include "gtkprivatetypebuiltins.h"
-#include "gtkstylepropertyprivate.h"
+#include "gtkcssstylepropertyprivate.h"
#include "gtkstylepropertiesprivate.h"
struct _GtkCssLookup {
_gtk_css_lookup_new (void)
{
GtkCssLookup *lookup;
- guint n = _gtk_style_property_get_count ();
+ guint n = _gtk_css_style_property_get_n_properties ();
lookup = g_malloc0 (sizeof (GtkCssLookup) + sizeof (const GValue *) * n);
lookup->missing = _gtk_bitmask_new ();
g_return_val_if_fail (lookup != NULL, NULL);
g_return_val_if_fail (parent == NULL || GTK_IS_STYLE_CONTEXT (parent), NULL);
- n = _gtk_style_property_get_count ();
+ n = _gtk_css_style_property_get_n_properties ();
props = gtk_style_properties_new ();
for (i = 0; i < n; i++)
{
- GtkStyleProperty *prop = _gtk_style_property_get (i);
+ GtkCssStyleProperty *prop = _gtk_css_style_property_lookup_by_id (i);
const GValue *result;
/* http://www.w3.org/TR/css3-cascade/#cascade
/* if the value of the winning declaration is ‘initial’,
* the initial value (see below) becomes the specified value.
*/
- result = _gtk_style_property_get_initial_value (prop);
+ result = _gtk_css_style_property_get_initial_value (prop);
break;
default:
/* This is part of (2) above */
}
else
{
- if (_gtk_style_property_is_inherit (prop))
+ if (_gtk_css_style_property_is_inherit (prop))
{
/* 4) if the property is inherited, the inherited value becomes
* the specified value.
{
/* 5) Otherwise, the initial value becomes the specified value.
*/
- result = _gtk_style_property_get_initial_value (prop);
+ result = _gtk_css_style_property_get_initial_value (prop);
}
}
_gtk_style_properties_set_property_by_property (props,
prop,
0,
- _gtk_style_property_get_initial_value (prop));
+ _gtk_css_style_property_get_initial_value (prop));
}
else
{
GValue value = { 0, };
/* Set NULL here and do the inheritance upon lookup? */
gtk_style_context_get_property (parent,
- _gtk_style_property_get_name (prop),
+ _gtk_style_property_get_name (GTK_STYLE_PROPERTY (prop)),
gtk_style_context_get_state (parent),
&value);
_gtk_style_properties_set_property_by_property (props,
property_value_free (value);
return;
}
-
- _gtk_bitmask_set (ruleset->set_styles, _gtk_style_property_get_id (prop), TRUE);
- g_hash_table_insert (ruleset->style, (gpointer) prop, value);
+ else if (GTK_IS_CSS_STYLE_PROPERTY (prop))
+ {
+ _gtk_bitmask_set (ruleset->set_styles,
+ _gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (prop)),
+ TRUE);
+ g_hash_table_insert (ruleset->style, prop, value);
+ }
+ else
+ {
+ g_assert_not_reached ();
+ }
}
static gboolean
while (g_hash_table_iter_next (&iter, &key, &val))
{
- GtkStyleProperty *prop = key;
+ GtkCssStyleProperty *prop = key;
PropertyValue *value = val;
_gtk_style_properties_set_property_by_property (props,
while (g_hash_table_iter_next (&iter, &key, &val))
{
- GtkStyleProperty *prop = key;
+ GtkCssStyleProperty *prop = key;
PropertyValue *value = val;
+ guint id = _gtk_css_style_property_get_id (prop);
- if (!_gtk_css_lookup_is_missing (lookup, _gtk_style_property_get_id (prop)))
+ if (!_gtk_css_lookup_is_missing (lookup, id))
continue;
- _gtk_css_lookup_set (lookup, _gtk_style_property_get_id (prop), &value->value);
+ _gtk_css_lookup_set (lookup, id, &value->value);
}
}
}
return property->id;
}
+gboolean
+_gtk_css_style_property_is_inherit (GtkCssStyleProperty *property)
+{
+ g_return_val_if_fail (property != NULL, FALSE);
+
+ return GTK_STYLE_PROPERTY (property)->flags & GTK_STYLE_PROPERTY_INHERIT ? TRUE : FALSE;
+}
+
+const GValue *
+_gtk_css_style_property_get_initial_value (GtkCssStyleProperty *property)
+{
+ g_return_val_if_fail (property != NULL, NULL);
+
+ return >K_STYLE_PROPERTY (property)->initial_value;
+}
+
guint _gtk_css_style_property_get_n_properties(void);
GtkCssStyleProperty * _gtk_css_style_property_lookup_by_id (guint id);
+gboolean _gtk_css_style_property_is_inherit (GtkCssStyleProperty *property);
guint _gtk_css_style_property_get_id (GtkCssStyleProperty *property);
+const GValue * _gtk_css_style_property_get_initial_value
+ (GtkCssStyleProperty *property);
G_END_DECLS
while (g_hash_table_iter_next (&iter, &key, &value))
{
- GtkStyleProperty *prop = key;
+ GtkCssStyleProperty *prop = key;
PropertyData *data = value;
const GValue *value;
guint id;
- id = _gtk_style_property_get_id (prop);
+ id = _gtk_css_style_property_get_id (prop);
if (!_gtk_css_lookup_is_missing (lookup, id))
continue;
}
void
-_gtk_style_properties_set_property_by_property (GtkStyleProperties *props,
- GtkStyleProperty *style_prop,
- GtkStateFlags state,
- const GValue *value)
+_gtk_style_properties_set_property_by_property (GtkStyleProperties *props,
+ GtkCssStyleProperty *style_prop,
+ GtkStateFlags state,
+ const GValue *value)
{
GtkStylePropertiesPrivate *priv;
PropertyData *prop;
}
g_value_copy (value, val);
- if (_gtk_style_property_get_value_type (style_prop) == G_VALUE_TYPE (value))
- g_param_value_validate (style_prop->pspec, val);
+ if (_gtk_style_property_get_value_type (GTK_STYLE_PROPERTY (style_prop)) == G_VALUE_TYPE (value))
+ g_param_value_validate (GTK_STYLE_PROPERTY (style_prop)->pspec, val);
}
/**
}
const GValue *
-_gtk_style_properties_peek_property (GtkStyleProperties *props,
- GtkStyleProperty *property,
- GtkStateFlags state)
+_gtk_style_properties_peek_property (GtkStyleProperties *props,
+ GtkCssStyleProperty *property,
+ GtkStateFlags state)
{
GtkStylePropertiesPrivate *priv;
PropertyData *prop;
#define __GTK_STYLE_PROPERTIES_PRIVATE_H__
#include "gtkstyleproperties.h"
-#include "gtkstylepropertyprivate.h"
+#include "gtkcssstylepropertyprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtksymboliccolorprivate.h"
va_list args);
const GValue * _gtk_style_properties_peek_property (GtkStyleProperties *props,
- GtkStyleProperty *property,
+ GtkCssStyleProperty *property,
GtkStateFlags state);
void _gtk_style_properties_set_property_by_property (GtkStyleProperties *props,
- GtkStyleProperty *property,
+ GtkCssStyleProperty *property,
GtkStateFlags state,
const GValue *value);
/*** API ***/
-guint
-_gtk_style_property_get_count (void)
-{
- return _gtk_css_style_property_get_n_properties ();
-}
-
-GtkStyleProperty *
-_gtk_style_property_get (guint id)
-{
- return GTK_STYLE_PROPERTY (_gtk_css_style_property_lookup_by_id (id));
-}
-
static void
css_string_funcs_init (void)
{
g_value_copy (&property->initial_value, value);
}
-gboolean
-_gtk_style_property_is_inherit (GtkStyleProperty *property)
-{
- g_return_val_if_fail (property != NULL, FALSE);
-
- return property->flags & GTK_STYLE_PROPERTY_INHERIT ? TRUE : FALSE;
-}
-
-guint
-_gtk_style_property_get_id (GtkStyleProperty *property)
-{
- g_return_val_if_fail (property != NULL, FALSE);
-
- if (GTK_IS_CSS_STYLE_PROPERTY (property))
- return _gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (property));
- else
- return 0;
-}
-
static gboolean
resolve_color (GtkStyleProperties *props,
GValue *value)
g_value_copy (val, val_out);
}
-const GValue *
-_gtk_style_property_get_initial_value (GtkStyleProperty *property)
-{
- g_return_val_if_fail (property != NULL, NULL);
-
- return &property->initial_value;
-}
-
GParameter *
_gtk_style_property_unpack (GtkStyleProperty *property,
const GValue *value,
else if (GTK_IS_CSS_STYLE_PROPERTY (property))
{
_gtk_style_properties_set_property_by_property (props,
- property,
+ GTK_CSS_STYLE_PROPERTY (property),
state,
value);
}
GtkStylePropertyContext *context,
GValue *value)
{
- const GValue *val;
g_return_if_fail (property != NULL);
g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props));
g_return_if_fail (context != NULL);
g_return_if_fail (value != NULL);
- val = _gtk_style_properties_peek_property (props, property, state);
g_value_init (value, property->pspec->value_type);
- if (val)
- _gtk_style_property_resolve (property, props, state, context, (GValue *) val, value);
+ if (GTK_IS_CSS_STYLE_PROPERTY (property))
+ {
+ const GValue *val;
+
+ val = _gtk_style_properties_peek_property (props, GTK_CSS_STYLE_PROPERTY (property), state);
+ if (val)
+ _gtk_style_property_resolve (property, props, state, context, (GValue *) val, value);
+ else
+ _gtk_style_property_default_value (property, props, state, value);
+ }
else if (GTK_IS_CSS_SHORTHAND_PROPERTY (property))
- _gtk_style_property_pack (property, props, state, context, value);
+ {
+ _gtk_style_property_pack (property, props, state, context, value);
+ }
else
- _gtk_style_property_default_value (property, props, state, value);
+ {
+ g_assert_not_reached ();
+ }
}
#define rgba_init(rgba, r, g, b, a) G_STMT_START{ \
GType _gtk_style_property_get_type (void) G_GNUC_CONST;
-guint _gtk_style_property_get_count (void);
-GtkStyleProperty * _gtk_style_property_get (guint id);
-
GtkStyleProperty * _gtk_style_property_lookup (const char *name);
const char * _gtk_style_property_get_name (GtkStyleProperty *property);
GtkStylePrintFunc print_func,
const GValue *initial_value);
-gboolean _gtk_style_property_is_inherit (GtkStyleProperty * property);
-guint _gtk_style_property_get_id (GtkStyleProperty * property);
-
-const GValue * _gtk_style_property_get_initial_value
- (GtkStyleProperty * property);
-
GParameter * _gtk_style_property_unpack (GtkStyleProperty * property,
const GValue *value,
guint *n_params);